/**
 * https://pintia.cn/problem-sets/994805046380707840/exam/problems/type/7?problemSetProblemId=994805063166312448&page=1
 */

#include<iostream>
#include<set>
using namespace std;
int main()
{
    set<int> m;
    int n;
    cin>>n;
    while(n--){
        int k;
        cin>>k;
        set<int>::iterator it;
        it=m.lower_bound(k);
        if(it!=m.end())
            m.erase(it);
        m.insert(k);
    }
    cout<<m.size()<<endl;
    return 0;
}